package com.xuanwu.jdk.demo;

import com.xuanwu.service.OrderService;
import com.xuanwu.service.impl.OrderServiceImpl;
import java.lang.reflect.Proxy;


public class TestJdkProxy {
    public static void main(String[] args) {
        //创建目标对象
        OrderService target=new OrderServiceImpl();

        //创建代理对象，并使用目标对象初始化
        OrderService  service=(OrderService) Proxy.newProxyInstance(
                target.getClass().getClassLoader(),//目标类的类加载器
                target.getClass().getInterfaces(), //目标类所实现的接口
                new OrderServiceInvocationHandler(target)) ; //增强业务逻辑


        service.payOrder();

    }
}
